package org.example.users.controller;

import org.example.users.entity.User;
import org.example.users.service.UserService;
import org.example.users.vo.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.Serializable;

@Component
@RestController
@RequestMapping("user")
public class UserController {
    @Autowired
    private UserService userService;
    @GetMapping()
    public R selectAll(){
        return R.success(userService.list());

    }
/*    @GetMapping("{id}")
    public R getById(@PathVariable Serializable id){

        return R.success(userService.getById(id));
    }*/

    @GetMapping("{id}")
    public User getById(@PathVariable Serializable id){

        return userService.getById(id);
    }
}
